﻿package cz.dadul.adventure.model
{
	/**
	 * ...
	 * @author Dadul
	 */
	import adobe.utils.CustomActions;
	import adobe.utils.ProductManager;
	import flash.display.*;
	import flash.events.*;
	import flash.geom.Point;
	
	public class Storage extends Element 
	{
		public static const ITEMS_GAP:uint = 5;
		
		public static const NAME:String = "storage";
		// Variables
		protected var _items:Sprite = new Sprite();
		
			
		public function Storage(mc:MovieClip) 
		{
			mc.stop();
			super(Storage.NAME, mc);
		}
	
		protected override function init():void {
			super.init();
			_items.y = 100;			
			addChild(_items);
		}

		/*
		 * Public
		 */ 
		
		 
		public override function hitTestObject(obj:DisplayObject):Boolean {
			return this._content.hitTestObject(obj);
		}
		 
		 
		public function addItem(item:PickableItem):void {
			dock(item);
			this._items.addChild(item);
			// Dock the item
			item.docked = true;
		}
		
		public function dock(item:PickableItem):void {
			// Reset the coordinates
			item.y = 0;
			item.x = this._items.numChildren * (PickableItem.MAX_WIDTH+Storage.ITEMS_GAP);			
		}
		
	}

}